// -----------------------------------------------
// Author:     code34 nicolas_boiteux@yahoo.fr
// Edited by:  Neumatic
// Warcontext: Unlock vehicle for engineer
// -----------------------------------------------

private ["_name","_text","_list","_object"];

_list = nearestObjects [position player, ["LandVehicle", "Air", "Tank", "Car"], 8];

if (count _list == 0) exitWith {hintSilent localize "STR_WC_MESSAGENOVEHICLENEARYOU"};

_object = _list select 0;
//A3 TODO: setVehicleInit
if (locked _object) then {
	_name = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "DisplayName");
	_text = format [localize "STR_WC_MESSAGEUNLOCKING", _name];

	wcgarbage = [format ["Unlock Vehicle: %1", _name], _text, "", 2] spawn WC_fnc_playerhint;
	//player playMove "AinvPknlMstpSlayWrflDnon_medic";
	sleep 2;

	if !(alive player) exitWith {};
	//_text = format[localize "STR_WC_MESSAGEISUNLOCKED", _name];
	//wcgarbage = [format ["Unlock Vehicle: %1", _name], _text, "", 1] spawn WC_fnc_playerhint;
	_object setVehicleInit "this lock false;";
	processInitCommands;
} else {
	_name = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "DisplayName");
	_text = format [localize "STR_WC_MESSAGELOCKING", _name];

	wcgarbage = [format ["Lock Vehicle: %1", _name], _text, "", 2] spawn WC_fnc_playerhint;
	//player playMove "AinvPknlMstpSlayWrflDnon_medic";
	sleep 2;

	if !(alive player) exitWith {};
	//_text = format [localize "STR_WC_MESSAGEISLOCKED", _name];
	//wcgarbage = [format ["Lock Vehicle: %1", _name], _text, "", 1] spawn WC_fnc_playerhint;
	_object setVehicleInit "this lock true;";
	processInitCommands;
};